<?php
include 'cookie.php';
?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI 管理系统 - 欢迎</title>
    <link href="https://cdn.staticfile.net/font-awesome/6.7.1/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.net/tailwindcss/2.2.9/tailwind.min.css" rel="stylesheet">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');
        
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .welcome-container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            padding: 3rem;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 1200px;
            text-align: center;
            border: 1px solid rgba(255, 255, 255, 0.5);
        }
        
        .welcome-header {
            margin-bottom: 2rem;
        }
        
        .welcome-header h1 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
            font-size: 2.5rem;
            color: #e91e63;
            margin-bottom: 0.5rem;
            letter-spacing: 1px;
        }
        
        .welcome-icon {
            font-size: 4rem;
            color: #e91e63;
            margin-bottom: 1.5rem;
        }
        
        .welcome-message {
            font-size: 1.2rem;
            color: #333;
            line-height: 1.6;
            margin-bottom: 2rem;
        }
        
        .key-info {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 1.5rem;
            margin: 2rem 0;
            text-align: left;
            border-left: 4px solid #e91e63;
        }
        
        .key-item {
            margin-bottom: 0.8rem;
            padding: 0.5rem 0;
            border-bottom: 1px dashed #eee;
        }
        
        .key-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
        }
        
        .key-label {
            font-weight: 600;
            color: #555;
            display: inline-block;
            width: 150px;
        }
        
        .logout-btn {
            background: linear-gradient(135deg, #e91e63, #ec407a);
            color: white;
            border: none;
            border-radius: 10px;
            padding: 0.75rem 2rem;
            font-size: 1.1rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-top: 1rem;
        }
        
        .logout-btn:hover {
            background: linear-gradient(135deg, #d81b60, #e91e63);
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(233, 30, 99, 0.4);
        }
    </style>
</head>
<body>
    <div class="welcome-container">
        <div class="welcome-header">
            <div class="welcome-icon">
                <i class="fas fa-check-circle"></i>
            </div>
            <h1><?php echo $current_org['cnorg'] ? $current_org['cnorg'].' - ' : ''; ?>AI 管理系统</h1>
            <p>身份验证成功</p>
        </div>
        
        <div class="welcome-message">
            <p>欢迎使用<?php echo $current_org['cnorg'] ? $current_org['cnorg'].' - ' : ''; ?>AI管理系统！您已成功通过身份验证。</p>
            <p>请妥善保管您的密钥，确保系统安全。</p>
        </div>
        
        <div class="key-info">
            <h3 class="font-bold text-lg mb-3 text-gray-800">当前密钥信息</h3>
            <div class="key-item">
                <span class="key-label">品红密码:</span> 
                <?php echo isset($_COOKIE['MIMA']) ? str_repeat('*', strlen($_COOKIE['MIMA'])) : '未设置'; ?>
            </div>
            <div class="key-item">
                <span class="key-label">修图密钥:</span> 
                <?php echo isset($_COOKIE['OR_KEY']) ? str_repeat('*', strlen($_COOKIE['OR_KEY'])) : '未设置'; ?>
            </div>
            <div class="key-item">
                <span class="key-label">反推密钥:</span> 
                <?php echo isset($_COOKIE['ZP_KEY']) ? str_repeat('*', strlen($_COOKIE['ZP_KEY'])) : '未设置'; ?>
            </div>
            <div class="key-item">
                <span class="key-label">工作流密钥:</span> 
                <?php echo isset($_COOKIE['BIZY_KEY']) ? str_repeat('*', strlen($_COOKIE['BIZY_KEY'])) : '未设置'; ?>
            </div>
        </div>
        
        <button class="logout-btn" onclick="logout()">
            <i class="fas fa-sign-out-alt mr-2"></i>初始化 登录信息
        </button>
    </div>

    <script>
        function logout() {
            // 清除所有cookie
            // 清除所有cookie
            document.cookie = "MIMA=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "OR_KEY=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "ZP_KEY=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "BIZY_KEY=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "NAME=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "cnorg=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "enorg=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            document.cookie = "sessiontime=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
            
            // 跳转回登录页面
            window.location.href = "index.php?login=<?php echo $login_org; ?>";
        }
    </script>
</body>
</html>